package com.coreJava.test02;

import java.util.concurrent.CyclicBarrier;

/**
 * 作者: LCG
 * 日期: 2019/9/3 17:11
 * 描述:
 */
public class MyCycRunable implements Runnable {

    private CyclicBarrier cyclicBarrier;

    private int time;

    public MyCycRunable(CyclicBarrier cyclicBarrier, int time) {
        this.cyclicBarrier = cyclicBarrier;
        this.time = time;
    }

    @Override
    public void run() {

        try {

            System.out.println("等待运动员"+Thread.currentThread().getName()+"就位");
            Thread.sleep(time*1000);
            System.out.println("====运动员"+Thread.currentThread().getName()+"到起跑线了");
            cyclicBarrier.await();


        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
